package com.heima.wemedia.controller.v1;


import com.heima.model.admin.dtos.WmNewsAuthPageDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmAuthDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/v1/news")
public class WmNewsController {

    @Autowired
    private WmNewsService wmNewsService;

    //文章列表
    @PostMapping("list")
    public ResponseResult list(@RequestBody WmNewsPageReqDto dto){

        return wmNewsService.findList(dto);
    }


    //发布文章
    @PostMapping("submit")
    public ResponseResult submitNews(@RequestBody WmNewsDto dto){

        return wmNewsService.submitNews(dto);
    }

    @PostMapping("/down_or_up")
    public ResponseResult downOrUp(@RequestBody WmNewsDto dto){
        return wmNewsService.downOrUp(dto);
    }

    @PostMapping("list_vo")
    public ResponseResult findNews(@RequestBody WmNewsAuthPageDto dto){
        return wmNewsService.findAuthList(dto);

    }

    /**
     * 管理端查看文章详情
     *
     * @param id
     * @return
     */
    @GetMapping("one_vo/{id}")
    public ResponseResult one_vo(@PathVariable Integer id) {
        return wmNewsService.one_vo(id);
    }

    /**
     * 人工审核文章通过
     * @param dto
     * @return
     */
    @PostMapping("/auth_pass")
    public ResponseResult auth_fail(@RequestBody WmAuthDto dto){
        return wmNewsService.authFailOrPass(dto);
    }

    /**
     * 人工审核文章驳回
     * @param dto
     * @return
     */
    @PostMapping("/auth_fail")
    public ResponseResult auth_pass(@RequestBody WmAuthDto dto){
        return wmNewsService.authFailOrPass(dto);
    }
}
